package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.PrivilegeUseLog;
import com.sc.nft.mapper.PrivilegeUseLogMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 优先购使用情况表(sc_privilege_use_log)数据DAO
 *
 * @author kancy
 * @since 2022-07-03 15:04:39
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class PrivilegeUseLogDao extends ServiceImpl<PrivilegeUseLogMapper, PrivilegeUseLog> {

    public int getFirstCount(String yearMonth, Collection<String> uuids){
        LambdaQueryWrapper<PrivilegeUseLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PrivilegeUseLog::getRecordMonth,yearMonth);
        wrapper.in(PrivilegeUseLog::getCollectionUuid,uuids);
        return count(wrapper);
    }

    public int getFirstCount(String yearMonth,  String uuids){
        LambdaQueryWrapper<PrivilegeUseLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PrivilegeUseLog::getRecordMonth,yearMonth);
        wrapper.eq(PrivilegeUseLog::getCollectionUuid,uuids);
        return count(wrapper);
    }

    /**
     * 某个月特权卡使用次数
     * @param yearMonth
     * @param uuids
     * @return
     *
     */
    public int getFirstCountByRecordMonth(String yearMonth,  String uuids){
        return baseMapper.getFirstCountByRecordMonth(yearMonth, uuids).size();
    }
}